package fr.afcepf.atod.gestionVP.data;

import java.io.Serializable;
import java.util.Collection;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name="pole")
public class Pole implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id 
	@GeneratedValue(strategy=GenerationType.AUTO)//auto_incrementation
	private Integer id;
	private String label;
	
	@OneToMany(fetch=FetchType.LAZY,mappedBy="pole")
	private Collection<Employe> employe;



	//******************************************************************************
	//GETTERS-SETTERS
//******************************************************************************
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public Collection<Employe> getEmploye() {
		return employe;
	}

	public void setEmploye(Collection<Employe> employe) {
		this.employe = employe;
	}

//******************************************************************************
	//CONSTRUCTEURS
//******************************************************************************
	 

	public Pole() {
	}

	public Pole(Integer id, String label) {
	super();
	this.id = id;
	this.label = label;
	}

	public Pole(Integer id, String label, Collection<Employe> employe) {
		super();
		this.id = id;
		this.label = label;
		this.employe = employe;
	}

//******************************************************************************
	//ToString/Equals
//******************************************************************************

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((label == null) ? 0 : label.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Pole other = (Pole) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (label == null) {
			if (other.label != null)
				return false;
		} else if (!label.equals(other.label))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Pole [id=" + id + ", label=" + label + "]";
	}
	
	
	
	

}
